﻿@model WishlistModel
@using SmartStore.Web.Models.ShoppingCart;

@{
    int attrMaxLength = Model.ShowProductImages ? 50 : 70;
}
<div class="shopbar-flyout-inner">
    <div class="no-items muted @(Model.Items.Count > 0 ? "hide" : "")">
        @T("Wishlist.CartIsEmpty")
    </div>
    @if (Model.Items.Count > 0)
    {
        <ul class="items unstyled">
            @for (int i = 0, length = Model.Items.Count; i < length; i++)
            {
                var item = Model.Items[i];
                string itemClass = "item clearfix";
                if (!Model.ShowProductImages)
                {
                    itemClass += " no-thumb";
                }
                if (i == 0)
                {
                    itemClass += " alpha";
                }
                
                <li class="@itemClass" data-transfer-src="true" style="position: relative">
                    @if (Model.ShowProductImages)
                    {
                        <figure class="picture pull-left">
                            <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="@item.Picture.Title">
                                <img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />
                            </a>
                        </figure>
                    }
                    <div class="quantity pull-left">
                        @(item.Quantity)<span class="times">x</span>
                    </div>
                    <div class="data pull-left">
                        <a class="name" href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="@item.ProductName">@item.ProductName</a>
                        @if (item.AttributeInfo.HasValue())
                        {
                            <br />    
                            <span class="attributes muted" title="@item.AttributeInfo">
                                @Html.Raw(item.AttributeInfo.Truncate(attrMaxLength))
                            </span>
                        }
                    </div>
                    <div class="action pull-left">
                         <a class="btn btn-mini ajax-cart-link" title='@T("ShoppingCart.AddToCart")' 
                             href="#"
                             data-href="@Url.Action("AddOneItemtoCartFromWishlist", "ShoppingCart", new { cartItemId = item.Id })"
                             data-name="@item.ProductName"
                             data-type="cart"
                             data-action="addfromwishlist">
                            <i class="icon-shopping-cart"></i>
                        </a>
                    </div>
                    <div class="price pull-right">
                        @item.UnitPrice
                    </div>
                    <a class="remove ajax-cart-link" 
                        href="#"
                        data-href='@Url.Action("DeleteCartItem", "ShoppingCart", new { cartItemId = item.Id, wishlistItem = true })' 
                        data-name="@item.ProductName"
                        data-type="wishlist"
                        data-action="remove" 
                        title='@T("Common.Remove")'>
                        <i class="icon-trash"></i>
                    </a>
                </li>
            }
            @if (Model.IgnoredProductsCount > 0)
            {
                string resId = "ShoppingCart.Mini.More.{0}".FormatInvariant(Model.IgnoredProductsCount == 1 ? "Singular" : "Plural");
                <li class="item more">
                    <a class="name" href="@Url.RouteUrl("Wishlist", new { customerGuid = Model.CustomerGuid })">
                        @(T(resId).ToString().FormatInvariant(Model.IgnoredProductsCount))...
                    </a>
                </li>
            }
        </ul>

        <div class="buttons clearfix">
            <a class="btn btn-primary btn-small pull-left" href="@Url.RouteUrl("Wishlist")">
                @T("Wishlist.Mini.ViewWishlist")
            </a>    
        </div>
    }
</div>

<script>
    $(function () {
        applyCommonPlugins("#shopbar-flyout-wishlist");
    });
</script>

